import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@fastgpt/service/common/response';
import { connectToDatabase } from '@/service/mongo';
import { MongoTeam } from '@fastgpt/service/support/user/team/teamSchema';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  try {
    await connectToDatabase();
    const { name } = req.query;
    // auth default team
    const team = await MongoTeam.findOne({ name: name });

    jsonRes(res, {
      data: team
    });
  } catch (err) {
    jsonRes(res, {
      code: 500,
      error: err
    });
  }
}
